#include "iostream"

using namespace std;

class Test
{
public:
	Test()
	{
		cout<<"我是构造函数，自动被调用了"<<endl;

		p = (char *)malloc(100);
		if(p == NULL)
		{
			cout << "func malloc() error" << endl;
			//return -1;  // can not return anything in the construction method
		}

		memset(p,0,100);
		strcpy(p, "11111");

	}
	Test(int a=0,int b=0)
	{
		cout<<"我是构造函数，自动被调用了"<<endl;
		cout << "a:" << a << "; b:" << b <<endl;

		p = (char *)malloc(100);
		if(p == NULL)
		{
			cout << "func malloc() error" << endl;
			//return -1; // can not return anything in the construction method
		}

		memset(p,0,100);
		strcpy(p, "11111");

		this->a = a;
		this->b = b;
	}
	~Test()
	{
		cout<<"我是析构函数，自动被调用了"<<endl;

		if(p != NULL)
		{
			free(p);
			p = NULL;
		}
	}
private:	
	int a;
	int b;
	char *p;
};

int main()
{

	{
		Test t2(2,3);
	}
	{
		Test t3 = Test(2,3);
	}
	return 0;
}